<template>
  <div class="dashboard-home">
    <!-- 欢迎区域 -->
    <div class="welcome-section">
      <div class="welcome-content">
        <h1>cursor3.7感谢一路陪伴</h1>
        <p>量子数字生命ai不远了</p>
      </div>
      <div class="welcome-decoration">
        <div class="decoration-circle circle-1"></div>
        <div class="decoration-circle circle-2"></div>
        <div class="decoration-circle circle-3"></div>
      </div>
    </div>

    <!-- 主要内容区域 -->
    <div class="dashboard-grid">
      <!-- 上传区域 -->
      <div class="dashboard-grid-item">
        <el-card class="upload-card" shadow="hover">
          <template #header>
            <div class="card-header">
              <div class="header-icon"><el-icon><Upload /></el-icon></div>
              <span>上传文档</span>
            </div>
          </template>
          <el-upload
            class="upload-area"
            drag
            :action="`${apiBaseUrl}/documents/`"
            :headers="uploadHeaders"
            :on-success="handleUploadSuccess"
            :on-error="handleUploadError"
            :before-upload="beforeUpload"
            :with-credentials="true"
            multiple
          >
            <div class="upload-content">
              <el-icon class="el-icon--upload"><Upload /></el-icon>
              <div class="el-upload__text">
                将文件拖到此处或 <em>点击上传</em>
              </div>
              <div class="upload-formats">
                支持上传 DOC, DOCX, PDF, XLS, XLSX, PPT, PPTX 等格式文件
              </div>
            </div>
          </el-upload>
        </el-card>
      </div>

      <!-- 图表区域 -->
      <div class="dashboard-grid-item">
        <el-card class="chart-card" shadow="hover">
          <template #header>
            <div class="card-header">
              <div class="header-icon"><el-icon><Histogram /></el-icon></div>
              <span>文件类型分布</span>
              <el-radio-group v-model="chartType" size="small">
                <el-radio-button value="pie">饼图</el-radio-button>
                <el-radio-button value="bar">柱状图</el-radio-button>
              </el-radio-group>
            </div>
          </template>
          <div class="chart-container" ref="chartRef" style="width: 100%; height: 300px;"></div>
        </el-card>
      </div>

      <!-- 快捷操作 -->
      <div class="dashboard-grid-item">
        <el-card class="quick-actions" shadow="hover">
          <template #header>
            <div class="card-header">
              <div class="header-icon"><el-icon><Menu /></el-icon></div>
              <span>快捷操作</span>
            </div>
          </template>
          <div class="actions-list">
            <el-button type="primary" @click="$router.push('/dashboard/documents')">
              <el-icon><Document /></el-icon>查看文档
            </el-button>
            <el-button type="success" @click="$router.push('/dashboard/upload')">
              <el-icon><Upload /></el-icon>上传文档
            </el-button>
            <el-button type="warning" @click="$router.push('/dashboard/exercises')">
              <el-icon><Reading /></el-icon>练习集
            </el-button>
            <el-button type="info" @click="$router.push('/dashboard/profile')">
              <el-icon><User /></el-icon>个人资料
            </el-button>
          </div>
        </el-card>
      </div>

      <!-- 最近活动 -->
      <div class="dashboard-grid-item">
        <el-card class="recent-activity" shadow="hover">
          <template #header>
            <div class="card-header">
              <div class="header-icon"><el-icon><Timer /></el-icon></div>
              <span>最近活动</span>
              <el-button link type="primary" @click="fetchActivities">
                <el-icon><Refresh /></el-icon>
              </el-button>
            </div>
          </template>
          <el-timeline>
            <el-timeline-item
              v-for="activity in recentActivities"
              :key="activity.id"
              :timestamp="activity.time"
              :type="activity.type"
              size="large"
            >
              <div class="activity-content">
                {{ activity.content }}
              </div>
            </el-timeline-item>
          </el-timeline>
        </el-card>
      </div>
    </div>

    <!-- 统计摘要 -->
    <div class="stat-summary">
      <el-card shadow="hover">
        <div class="summary-content">
          <div class="summary-item">
            <div class="summary-icon">
              <el-icon><Document /></el-icon>
            </div>
            <div class="summary-info">
              <div class="summary-value">{{ stats.totalDocuments }}</div>
              <div class="summary-label">文档总数</div>
            </div>
          </div>
          <div class="summary-divider"></div>
          <div class="summary-item">
            <div class="summary-icon">
              <el-icon><Download /></el-icon>
            </div>
            <div class="summary-info">
              <div class="summary-value">{{ stats.totalDownloads }}</div>
              <div class="summary-label">总下载次数</div>
            </div>
          </div>
          <div class="summary-divider"></div>
          <div class="summary-item">
            <div class="summary-icon">
              <el-icon><Files /></el-icon>
            </div>
            <div class="summary-info">
              <div class="summary-value">{{ stats.totalSize }}</div>
              <div class="summary-label">文件总大小</div>
            </div>
          </div>
          <div class="summary-divider"></div>
          <div class="summary-item">
            <div class="summary-icon">
              <el-icon><Histogram /></el-icon>
            </div>
            <div class="summary-info">
              <div class="summary-value">{{ stats.fileTypes }}</div>
              <div class="summary-label">文件类型</div>
            </div>
          </div>
        </div>
      </el-card>
    </div>

    <!-- 上传列表 -->
    <el-card class="upload-list" v-if="uploadedFiles.length > 0" shadow="hover">
      <template #header>
        <div class="card-header">
          <div class="header-icon"><el-icon><Document /></el-icon></div>
          <span>最近上传文件</span>
          <el-button link type="primary" @click="fetchUploadedFiles">
            <el-icon><Refresh /></el-icon>
          </el-button>
        </div>
      </template>
      
      <el-table 
        :data="uploadedFiles.slice(0, 5)" 
        style="width: 100%"
        :header-cell-style="{ background: 'rgba(255, 255, 255, 0.05)' }"
        stripe
        border
      >
        <el-table-column prop="title" label="文件名" min-width="200">
          <template #default="{ row }">
            <div class="file-name">
              <el-icon :size="20" class="file-icon">
                <component :is="getFileIcon(row.file_type)" />
              </el-icon>
              <span>{{ row.title }}</span>
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="file_type" label="类型" width="100" align="center" />
        <el-table-column prop="file_size_formatted" label="大小" width="100" align="center" />
        <el-table-column prop="upload_time" label="上传时间" width="180" align="center">
          <template #default="{ row }">
            {{ formatDate(row.upload_time) }}
          </template>
        </el-table-column>
        <el-table-column fixed="right" label="操作" width="180" align="center">
          <template #default="scope">
            <el-button link type="primary" @click="handleDownload(scope.row)" size="small">
              <el-icon><Download /></el-icon>下载
            </el-button>
            <el-button link type="danger" @click="handleDelete(scope.row)" size="small">
              <el-icon><Delete /></el-icon>删除
            </el-button>
          </template>
        </el-table-column>
      </el-table>
      
      <div class="view-all-link" v-if="uploadedFiles.length > 5">
        <el-button link type="primary" @click="$router.push('/dashboard/documents')">
          查看全部 {{ uploadedFiles.length }} 个文件
          <el-icon><ArrowRight /></el-icon>
        </el-button>
      </div>
    </el-card>
  </div>
</template>

<script setup>
import { ref, onMounted, watch, computed, onUnmounted, nextTick } from 'vue'
import { Document, Download, Files, Upload, User, Histogram, Refresh, Menu, Timer, Delete, ArrowRight, Reading } from '@element-plus/icons-vue'
import http from '../utils/axios'  // 使用配置好的axios实例
import * as echarts from 'echarts'
import { ElMessage, ElMessageBox } from 'element-plus'

const chartRef = ref(null)
const chartType = ref('pie')
let chartInstance = ref(null)

const stats = ref({
  totalDocuments: 0,
  totalDownloads: 0,
  totalSize: '0 B',
  fileTypes: 0
})

const recentActivities = ref([
  {
    id: 1,
    content: '上传了新文档 "项目计划书.docx"',
    time: '2024-03-09 14:30',
    type: 'primary'
  },
  {
    id: 2,
    content: '下载了文档 "会议记录.pdf"',
    time: '2024-03-09 13:15',
    type: 'success'
  },
  {
    id: 3,
    content: '删除了文档 "旧版文档.doc"',
    time: '2024-03-09 11:20',
    type: 'danger'
  }
])

// 修改上传相关的计算属性
const apiBaseUrl = computed(() => `${import.meta.env.VITE_API_URL}/api`)

const uploadHeaders = computed(() => {
  const token = localStorage.getItem('access_token')
  return {
    'Authorization': token ? `Bearer ${token}` : '',
    'X-Requested-With': 'XMLHttpRequest',
    'Accept': 'application/json'
  }
})

const uploadedFiles = ref([])

const fetchStats = async () => {
  try {
    const response = await http.get('/dashboard/stats/')
    stats.value = response.data
  } catch (error) {
    console.error('获取统计数据失败:', error)
    stats.value = {
      totalDocuments: 0,
      totalDownloads: 0,
      totalSize: '0 B',
      fileTypes: 0
    }
  }
}

const formatFileSize = (bytes) => {
  if (bytes === 0) return '0 B'
  const k = 1024
  const sizes = ['B', 'KB', 'MB', 'GB', 'TB']
  const i = Math.floor(Math.log(bytes) / Math.log(k))
  return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i]
}

const updateChart = () => {
  // 确保DOM已经渲染完成
  nextTick(() => {
    // 延迟一点时间确保DOM完全加载
    setTimeout(() => {
      if (!chartInstance.value) {
        // 初始化图表
        if (chartRef.value) {
          try {
            // 添加passive选项
            chartInstance.value = echarts.init(chartRef.value, null, {
              renderer: 'canvas',
              useDirtyRect: false,
              // 添加passive选项，解决滚轮事件警告
              useCoarsePointer: true,
              pointerOptions: {
                mouse: ['mousemove', 'mouseup', 'mousedown', 'click', 'dblclick'],
                touch: ['touchstart', 'touchmove', 'touchend'],
                auto: true
              }
            })
            
            // 手动设置echarts的zrender dom事件监听器为passive
            const zr = chartInstance.value.getZr();
            const handler = zr.handler;
            const proxy = handler.proxy;
            
            // 添加passive标志到wheel和mousewheel事件
            const originalAddEventListener = proxy.dom.addEventListener;
            proxy.dom.addEventListener = function(eventName, eventHandler, options) {
              if (eventName === 'wheel' || eventName === 'mousewheel') {
                options = Object.assign({}, options, { passive: true });
              }
              return originalAddEventListener.call(this, eventName, eventHandler, options);
            };
          } catch (e) {
            console.log('图表初始化失败', e)
            return
          }
        } else {
          console.log('找不到图表DOM元素，稍后重试')
          return
        }
      }
      
      // 准备图表数据
      const fileTypes = {}
      
      // 从uploadedFiles中获取文件类型数据
      if (uploadedFiles.value && Array.isArray(uploadedFiles.value)) {
        uploadedFiles.value.forEach(doc => {
          const fileType = doc.file_type || '未知'
          if (fileTypes[fileType]) {
            fileTypes[fileType]++
          } else {
            fileTypes[fileType] = 1
          }
        })
      }
      
      // 转换为图表数据格式
      const chartData = Object.keys(fileTypes).map(type => ({
        name: type,
        value: fileTypes[type]
      }))
      
      // 如果没有数据，添加一个占位数据
      if (chartData.length === 0) {
        chartData.push({
          name: '暂无数据',
          value: 1
        })
      }
      
      // 设置图表选项
      const option = {
        backgroundColor: 'transparent',
        tooltip: {
          trigger: 'item',
          formatter: '{a} <br/>{b}: {c} ({d}%)'
        },
        legend: {
          orient: 'vertical',
          left: 10,
          top: 'center',
          textStyle: {
            color: '#fff'
          }
        },
        series: [
          {
            name: '文件类型',
            type: chartType.value === 'pie' ? 'pie' : 'bar',
            radius: ['40%', '70%'],
            avoidLabelOverlap: false,
            itemStyle: {
              borderRadius: 10,
              borderColor: 'rgba(0, 0, 0, 0.1)',
              borderWidth: 2
            },
            label: {
              show: false,
              position: 'center'
            },
            emphasis: {
              label: {
                show: true,
                fontSize: '18',
                fontWeight: 'bold',
                color: '#fff'
              }
            },
            labelLine: {
              show: false
            },
            data: chartData
          }
        ]
      }
      
      // 如果是柱状图，添加x轴和y轴配置
      if (chartType.value === 'bar') {
        option.xAxis = {
          type: 'category',
          data: chartData.map(item => item.name),
          axisLine: {
            lineStyle: {
              color: 'rgba(255, 255, 255, 0.3)'
            }
          },
          axisLabel: {
            color: '#fff'
          }
        }
        option.yAxis = {
          type: 'value',
          axisLine: {
            lineStyle: {
              color: 'rgba(255, 255, 255, 0.3)'
            }
          },
          axisLabel: {
            color: '#fff'
          },
          splitLine: {
            lineStyle: {
              color: 'rgba(255, 255, 255, 0.1)'
            }
          }
        }
        // 修改series配置适应柱状图
        option.series[0].radius = undefined
        option.series[0].label = undefined
        option.series[0].labelLine = undefined
        option.series[0].emphasis = {
          itemStyle: {
            color: '#805AD5'
          }
        }
      }
      
      // 应用图表选项
      if (chartInstance.value) {
        chartInstance.value.setOption(option)
      }
    }, 100); // 延迟100ms确保DOM已完全渲染
  })
}

// 监听图表类型变化
watch(chartType, () => {
  if (chartInstance.value) {
    chartInstance.value.dispose()
    chartInstance.value = null
  }
  
  // 确保DOM已加载完成
  nextTick(() => {
    if (chartRef.value) {
      try {
        // 使用相同的ECharts初始化选项
        chartInstance.value = echarts.init(chartRef.value, null, {
          renderer: 'canvas',
          useDirtyRect: false,
          // 添加passive选项，解决滚轮事件警告
          useCoarsePointer: true,
          pointerOptions: {
            mouse: ['mousemove', 'mouseup', 'mousedown', 'click', 'dblclick'],
            touch: ['touchstart', 'touchmove', 'touchend'],
            auto: true
          }
        })
        updateChart()
      } catch (e) {
        console.log('图表类型切换时初始化失败', e)
      }
    } else {
      // 如果DOM元素不存在，延迟获取数据
      setTimeout(() => fetchStats(), 100)
    }
  })
})

// 处理窗口大小变化
const handleResize = () => {
  if (chartInstance.value) {
    chartInstance.value.resize()
  }
}

const fetchActivities = async () => {
  try {
    const response = await http.get('/dashboard/activities/')
    recentActivities.value = response.data
  } catch (error) {
    console.error('获取最近活动失败:', error)
  }
}

// 修改上传成功处理函数
const handleUploadSuccess = (response) => {
  ElMessage.success('上传成功')
  fetchUploadedFiles()
  fetchStats()
}

// 修改上传失败处理函数
const handleUploadError = (error) => {
  ElMessage.error('上传失败：' + (error.message || '未知错误'))
}

// 修改上传前的验证函数
const beforeUpload = (file) => {
  const allowedTypes = [
    'application/msword',
    'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
    'application/pdf',
    'application/vnd.ms-excel',
    'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
    'application/vnd.ms-powerpoint',
    'application/vnd.openxmlformats-officedocument.presentationml.presentation',
    'text/plain'
  ]
  
  if (!allowedTypes.includes(file.type)) {
    ElMessage.error(`不支持的文件类型: ${file.type}`)
    return false
  }

  // 检查文件大小（例如限制为1GB）
  const maxSize = 1 * 1024 * 1024 * 1024 // 1GB
  if (file.size > maxSize) {
    ElMessage.error('文件大小不能超过1GB')
    return false
  }

  return true
}

const fetchUploadedFiles = async () => {
  try {
    const response = await http.get('/documents/')
    uploadedFiles.value = response.data.results || []
  } catch (error) {
    console.error('获取上传文件列表失败:', error)
    uploadedFiles.value = []
  }
}

const handleDelete = async (file) => {
  try {
    await ElMessageBox.confirm('确定要删除这个文件吗？', '删除确认', {
      type: 'warning'
    })
    await http.delete(`/documents/${file.id}/`)
    ElMessage.success('删除成功')
    fetchUploadedFiles()
    fetchStats()
  } catch (error) {
    if (error !== 'cancel') {
      console.error('删除失败:', error)
      ElMessage.error('删除失败')
    }
  }
}

const formatDate = (dateString) => {
  const date = new Date(dateString)
  return date.toLocaleString('zh-CN', {
    year: 'numeric',
    month: '2-digit',
    day: '2-digit',
    hour: '2-digit',
    minute: '2-digit'
  })
}

// 获取文件图标
const getFileIcon = (fileType) => {
  if (!fileType) return Document
  
  const fileTypeMap = {
    'pdf': Document,
    'doc': Document,
    'docx': Document,
    'xls': Files,
    'xlsx': Files,
    'ppt': Document,
    'pptx': Document,
    'txt': Document
  }
  
  return fileTypeMap[fileType.toLowerCase()] || Document
}

// 下载文件
const handleDownload = async (file) => {
  try {
    const response = await http.get(`/documents/${file.id}/download/`, {
      responseType: 'blob'
    })
    
    const url = window.URL.createObjectURL(new Blob([response.data]))
    const link = document.createElement('a')
    link.href = url
    link.setAttribute('download', file.title)
    document.body.appendChild(link)
    link.click()
    document.body.removeChild(link)
    window.URL.revokeObjectURL(url)
    
    ElMessage.success('下载成功')
  } catch (error) {
    console.error('下载失败:', error)
    ElMessage.error('下载失败')
  }
}

// 组件卸载时清理图表实例
onUnmounted(() => {
  if (chartInstance.value) {
    chartInstance.value.dispose()
    chartInstance.value = null
  }
  window.removeEventListener('resize', handleResize)
})

// 添加一个全局样式，使所有滚动事件都是被动的
const addPassiveSupport = () => {
  // 检测浏览器是否支持passive选项
  let supportsPassive = false
  try {
    const opts = Object.defineProperty({}, 'passive', {
      get: function() {
        supportsPassive = true
        return true
      }
    })
    window.addEventListener('testPassive', null, opts)
    window.removeEventListener('testPassive', null, opts)
  } catch (e) {}

  // 如果支持passive选项，为document添加被动滚动事件监听器
  if (supportsPassive) {
    const wheelOpt = { passive: true }
    const wheelEvent = 'onwheel' in document.createElement('div') ? 'wheel' : 'mousewheel'
    
    // 为document添加被动滚动事件监听器
    document.addEventListener(wheelEvent, () => {}, wheelOpt)
    document.addEventListener('touchstart', () => {}, wheelOpt)
  }
}

// 在组件挂载时添加被动事件支持
onMounted(() => {
  // 添加被动事件支持
  addPassiveSupport()
  
  // 确保应用深色主题
  document.documentElement.classList.add('dark')
  
  // 初始化ECharts的函数，包含passive事件设置
  const initializeChart = () => {
    if (chartRef.value && !chartInstance.value) {
      try {
        // 使用相同的ECharts初始化选项
        chartInstance.value = echarts.init(chartRef.value, null, {
          renderer: 'canvas',
          useDirtyRect: false,
          // 添加passive选项，解决滚轮事件警告
          useCoarsePointer: true,
          pointerOptions: {
            mouse: ['mousemove', 'mouseup', 'mousedown', 'click', 'dblclick'],
            touch: ['touchstart', 'touchmove', 'touchend'],
            auto: true
          }
        })
        
        // 手动设置echarts的zrender dom事件监听器为passive
        const zr = chartInstance.value.getZr();
        const handler = zr.handler;
        const proxy = handler.proxy;
        
        // 添加passive标志到wheel和mousewheel事件
        const originalAddEventListener = proxy.dom.addEventListener;
        proxy.dom.addEventListener = function(eventName, eventHandler, options) {
          if (eventName === 'wheel' || eventName === 'mousewheel') {
            options = Object.assign({}, options, { passive: true });
          }
          return originalAddEventListener.call(this, eventName, eventHandler, options);
        };
        
        updateChart()
        
        // 添加窗口大小变化时重绘图表
        window.addEventListener('resize', handleResize, { passive: true })
        return true;
      } catch (e) {
        console.log('图表初始化失败，将在窗口加载完成后重试', e)
        return false;
      }
    }
    return false;
  }
  
  // 先获取数据
  fetchUploadedFiles().then(() => {
    fetchStats().then(() => {
      // 确保DOM已加载完成
      nextTick(() => {
        // 延迟一点时间确保图表容器已渲染
        setTimeout(() => {
          if (!initializeChart()) {
            // 如果初始化失败，在window.onload时重试
            window.addEventListener('load', () => {
              initializeChart();
            }, { passive: true })
          }
        }, 200)
      })
    })
  })
})
</script>

<style scoped>
.dashboard-home {
  padding: 20px;
  color: var(--el-text-color-primary);
  min-height: 100vh; /* 确保即使内容少也能填满整个视口高度 */
}

.welcome-section {
  background: linear-gradient(135deg, rgba(107, 70, 193, 0.2) 0%, rgba(72, 41, 178, 0.2) 100%);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 40px;
  margin-bottom: 30px;
  text-align: center;
  position: relative;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  transition: all 0.5s ease;
}

.welcome-section:hover {
  transform: translateY(-5px);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
}

.welcome-content {
  position: relative;
  z-index: 2;
}

.welcome-content h1 {
  font-size: 36px;
  margin-bottom: 16px;
  background: linear-gradient(90deg, var(--el-color-primary) 0%, var(--el-color-primary-light-3) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: fadeInDown 1s ease;
}

.welcome-content p {
  font-size: 18px;
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 30px;
  animation: fadeInUp 1s ease 0.3s both;
}

/* 装饰元素 */
.welcome-decoration {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

.decoration-circle {
  position: absolute;
  border-radius: 50%;
  opacity: 0.3;
}

.circle-1 {
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, var(--el-color-primary-light-5) 0%, transparent 70%);
  top: -150px;
  right: -100px;
  animation: pulse 15s infinite alternate;
}

.circle-2 {
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, var(--el-color-primary-light-7) 0%, transparent 70%);
  bottom: -100px;
  left: -50px;
  animation: pulse 10s infinite alternate-reverse;
}

.circle-3 {
  width: 150px;
  height: 150px;
  background: radial-gradient(circle, var(--el-color-primary-light-9) 0%, transparent 70%);
  top: 50%;
  left: 30%;
  animation: pulse 12s infinite alternate;
}

/* 统计卡片网格布局 */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px;
  margin-bottom: 30px;
}

.dashboard-grid-item {
  min-height: 300px;
  transition: all 0.3s ease;
}

.dashboard-grid-item:hover {
  transform: translateY(-5px);
}

/* 卡片样式优化 */
.upload-card, .chart-card, .quick-actions, .recent-activity, .upload-list {
  height: 100%;
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  overflow: hidden;
  transition: all 0.3s ease;
}

.upload-card:hover, .chart-card:hover, .quick-actions:hover, .recent-activity:hover, .upload-list:hover {
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
  border-color: rgba(255, 255, 255, 0.2);
}

/* 卡片头部样式 */
.card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.header-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(107, 70, 193, 0.2);
  color: var(--el-color-primary-light-3);
}

/* 上传区域样式 */
.upload-area {
  padding: 20px;
  background: transparent;
}

.upload-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  border-radius: 12px;
  background: transparent;
  border: 2px dashed rgba(255, 255, 255, 0.2);
  transition: all 0.3s ease;
}

.upload-content:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--el-color-primary-light-5);
}

.el-icon--upload {
  font-size: 48px;
  color: var(--el-color-primary-light-5);
  margin-bottom: 16px;
}

.el-upload__text {
  font-size: 16px;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 8px;
}

.upload-formats {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.5);
  text-align: center;
  margin-top: 10px;
}

/* 修改el-upload组件的默认样式 */
:deep(.el-upload-dragger) {
  background: transparent;
  border: none;
  width: 100%;
}

:deep(.el-upload-dragger:hover) {
  background: transparent;
  border: none;
}

:deep(.el-upload-dragger.is-dragover) {
  background: rgba(255, 255, 255, 0.05);
  border: none;
}

/* 快捷操作按钮样式 */
.actions-list {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.actions-list .el-button {
  height: 50px;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 500;
  justify-content: flex-start;
  padding: 0 20px;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  border-width: 0;
}

.actions-list .el-button:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.actions-list .el-icon {
  margin-right: 12px;
  font-size: 20px;
}

/* 最近活动时间线样式 */
.el-timeline {
  padding: 20px;
  max-height: 300px;
  overflow-y: auto;
}

.el-timeline-item__node {
  background-color: var(--el-color-primary);
}

.el-timeline-item__tail {
  border-left-color: rgba(255, 255, 255, 0.1);
}

.el-timeline-item__timestamp {
  color: rgba(255, 255, 255, 0.5);
}

.activity-content {
  color: rgba(255, 255, 255, 0.8);
  font-size: 14px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 8px;
  transition: all 0.3s ease;
}

.activity-content:hover {
  background: rgba(255, 255, 255, 0.05);
  transform: translateX(5px);
}

/* 文件列表样式 */
.upload-list {
  margin-top: 30px;
  margin-bottom: 30px;
}

.file-name {
  display: flex;
  align-items: center;
  gap: 10px;
}

.file-icon {
  color: var(--el-color-primary-light-5);
}

.view-all-link {
  display: flex;
  justify-content: center;
  margin-top: 20px;
  padding: 10px;
}

.view-all-link .el-button {
  font-size: 16px;
  transition: all 0.3s ease;
}

.view-all-link .el-button:hover {
  transform: translateX(5px);
}

/* 统计摘要样式 */
.stat-summary {
  margin-bottom: 30px;
}

.summary-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  flex-wrap: wrap;
}

.summary-item {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 10px 20px;
  flex: 1;
  min-width: 200px;
}

.summary-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 50px;
  border-radius: 12px;
  background: rgba(107, 70, 193, 0.2);
  color: var(--el-color-primary-light-3);
  font-size: 24px;
}

.summary-info {
  display: flex;
  flex-direction: column;
}

.summary-value {
  font-size: 24px;
  font-weight: bold;
  color: var(--el-color-primary-light-3);
}

.summary-label {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.6);
}

.summary-divider {
  width: 1px;
  height: 50px;
  background: rgba(255, 255, 255, 0.1);
  margin: 0 10px;
}

/* 动画效果 */
@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0% {
    transform: scale(1);
    opacity: 0.3;
  }
  50% {
    transform: scale(1.1);
    opacity: 0.5;
  }
  100% {
    transform: scale(1);
    opacity: 0.3;
  }
}

/* 响应式布局优化 */
@media (max-width: 768px) {
  .welcome-section {
    padding: 30px 20px;
  }
  
  .welcome-content h1 {
    font-size: 28px;
  }
  
  .welcome-content p {
    font-size: 16px;
  }
  
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  
  .summary-content {
    flex-direction: column;
    gap: 20px;
  }
  
  .summary-divider {
    width: 80%;
    height: 1px;
    margin: 10px 0;
  }
  
  .card-header {
    flex-wrap: wrap;
  }
}

/* 图表容器样式 */
.chart-container {
  width: 100%;
  height: 300px !important;
  min-height: 300px;
}
</style> 